from rest_framework import serializers
from attractions import models


class CitySerializer(serializers.ModelSerializer):
    class Meta:
        model = models.City
        fields = '__all__'


class AttractionsSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Attractions
        fields = '__all__'


class CommentSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.UserComment
        fields = '__all__'
        depth = 2


class AttractionTickeSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.AttractionTicke
        fields = '__all__'
        depth = 1


class ScenicSpotSerializer(serializers.ModelSerializer):
    id = serializers.CharField(read_only=True)  # 处理雪花ID精度问题

    class Meta:
        model = models.ScenicSpot
        fields = ['id', 'name', 'province', 'recommend_time', 'tags']
        extra_kwargs = {
            'tags': {'required': False}
        }
